import { Controller, Get, Post, Body, Patch, Param, Delete } from '@nestjs/common'
import { CategoryService } from './category.service'
import { CreateCategoryDto } from './dto/create-category.dto'

@Controller('category')
export class CategoryController {
   constructor(private readonly categoryService: CategoryService) {}

   @Get()
   findAll() {
      return this.categoryService.findAll()
   }

   // 删除
   @Delete(':id')
   remove(@Param('id') id: number) {
      return this.categoryService.delete(+id)
   }

   // 添加
   @Post(':id')
   create(@Body() createCategoryDto: CreateCategoryDto) {
      return this.categoryService.add(createCategoryDto)
   }

   // 更新
   @Patch(':id')
   update(@Param('id') id: number, @Body() createCategoryDto: CreateCategoryDto) {
      return this.categoryService.update(+id, createCategoryDto)
   }
}
